package com.woniuxy.service.impl;

import com.woniuxy.dao.RbacPermDao;
import com.woniuxy.entity.RbacPerm;
import com.woniuxy.service.RbacPermService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;


/**
 * (RbacPerm)表服务实现类
 *
 * @author makejava
 * @since 2021-04-25 23:04:55
 */
@Service("rbacPermService")
public class RbacPermServiceImpl implements RbacPermService {

    @Autowired(required = false)
    private RbacPermDao rbacPermDao;

    /**
     * 通过ID查询单条数据
     *
     * @param id 主键
     * @return 实例对象
     */
    @Override
    public RbacPerm queryById(Integer id) {
        return this.rbacPermDao.queryById(id);
    }

    /**
     * 查询多条数据
     *
     * @return 对象列表
     */
    @Override
    public List<RbacPerm> queryAllByLimit() {
        return this.rbacPermDao.queryAllByLimit();
    }

    /**
     * 新增数据
     *
     * @param rbacPerm 实例对象
     * @return 实例对象
     */
    @Override
    public RbacPerm insert(RbacPerm rbacPerm) {
        this.rbacPermDao.insert(rbacPerm);
        return rbacPerm;
    }

    /**
     * 修改数据
     *
     * @param rbacPerm 实例对象
     * @return 实例对象
     */
    @Override
    public RbacPerm update(RbacPerm rbacPerm) {
        this.rbacPermDao.update(rbacPerm);
        return this.queryById(rbacPerm.getId());
    }

    /**
     * 通过主键删除数据
     *
     * @param id 主键
     * @return 是否成功
     */
    @Override
    public boolean deleteById(Integer id) {
        return this.rbacPermDao.deleteById(id) > 0;
    }

    @Override
    public List<RbacPerm> search(RbacPerm rbacPerm) {
        return this.rbacPermDao.queryAll(rbacPerm);
    }

    @Override
    public List<RbacPerm> findForRole(String roles) {
        return this.rbacPermDao.findForRole(roles);
    }
}
